<template>
  <div class="high-container">
    <div class="title">评估报告</div>
    <div class="content-info">
      <div class="list flex items-middle">
        <div class="name">评估总分：</div>
        <div class="count">{{companyInfo.totalScore || '0'}}分</div>
      </div>
      <div class="list tips flex items-middle">{{ companyInfo.message }}</div>
      <div class="list flex items-middle">
        <div class="name">评估总分：</div>
        <div class="lable-info">{{companyInfo.companyName || '--'}}</div>
      </div>
      <div class="list flex items-middle">
        <div class="name">项目名称：</div>
        <div class="lable-info">{{companyInfo.evaluationType || '--'}}</div>
      </div>
    </div>
    <div class="content-info">
      <div class="content-title">
        <p>评估结果</p>
      </div>
      <div class="content-table">
        <table cellspacing="0" cellpadding="0" border="1">
          <tbody>
            <tr>
              <th class="half table-cell text-gray">类别</th>
              <th class="flex-1 table-cell text-gray">得分</th>
            </tr>
            <tr>
              <td class="table-cell">自主研发发明专利</td>
              <td class="table-cell num" rowspan="4">{{companyInfo.patentTotalScore || '0'}}</td>
            </tr>
            <tr>
              <td class="table-cell">受让发明专利</td>
            </tr>
            <tr>
              <td class="table-cell">实用新型</td>
            </tr>
            <tr>
              <td class="table-cell">软件著作权</td>
            </tr>
            <tr>
              <td class="table-cell">主营业务增长率</td>
              <td class="table-cell num">{{companyInfo.growthRateScoreOfMainBusiness || '0'}}</td>
            </tr>
            <tr>
              <td class="table-cell">2021研发费占比</td>
              <td class="table-cell num">{{companyInfo.researchCostScore || '0'}}</td>
            </tr>
            <tr>
              <td class="table-cell">资产负债率</td>
              <td class="table-cell num">{{companyInfo.assetsDebtRatioScore || '0'}}</td>
            </tr>
            <tr>
              <td class="table-cell">主导产品所属领域</td>
              <td class="table-cell num">{{companyInfo.productFieldScore || '0'}}</td>
            </tr>
            <tr>
              <td class="table-cell">2021年主营业务收入总额占营业收入总额比重</td>
              <td class="table-cell num">{{companyInfo.proportionScore || '0'}}</td>
            </tr>
          </tbody>
        </table>
      </div>
    </div>
    <div class="content-info">
      <div class="content-title">
        <p>评估说明</p>
      </div>
      <div class="explain">
        公告条件：
        <br />1、评价得分60分以上（其中创新能力指标得分不低于20 分、成长性指标及专业化指标得分均不低于15 分）；
        <br />2、或以下条件之一：
        <br />①、近三年内获得过国家级、省级科技奖励；
        <br />②、获得高新技术企业、国家级技术创新示范企业；知识产权优势企业和知识产权示范企业等荣誉（均为有效期内）；
        <br />③、拥有经认定的省部级以上研发机构；
        <br />④、近三年新增股权融资总额（合格机构投资者的实缴额）500万元以上。
      </div>
    </div>
    <div class="content-info flex flex-center">
      <el-button type="primary" size="medium" @click="onDialog">精准测评</el-button>
    </div>
    <el-dialog title="精准测评" :visible.sync="visible" @close="close">
      <el-form label-width="200px">
        <el-form-item :label="`${thisYear-2}年主营业务收入(万元)：`">
          <el-input
            v-model="form.frontYearMainOperatingIncome"
            style="width:250px"
            placeholder="请输入"
          />
        </el-form-item>
        <el-form-item :label="`${thisYear-1}年主营业务收入(万元)：`">
          <el-input
            v-model="form.lastYearMainOperatingIncome"
            style="width:250px"
            placeholder="请输入"
          />
        </el-form-item>
        <el-form-item :label="`${thisYear-1}年研发费(万元)：`">
          <el-input v-model="form.lastYearResearchCost" style="width:250px" placeholder="请输入" />
        </el-form-item>
        <el-form-item :label="`${thisYear-1}年总资产(万元)：`">
          <el-input v-model="form.lastYearTotalAssets" style="width:250px" placeholder="请输入" />
        </el-form-item>
        <el-form-item :label="`${thisYear-1}年总负债(万元)：`">
          <el-input v-model="form.lastYearTotalLiabilities" style="width:250px" placeholder="请输入" />
        </el-form-item>
        <el-form-item :label="`${thisYear-1}年营业收入(万元)：`">
          <el-input v-model="form.lastYearOperatingIncome" style="width:250px" placeholder="请输入" />
        </el-form-item>
      </el-form>
      <div slot="footer">
        <el-button type="primary" @click="onSave">提 交</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import { getDeclareInnovate } from "../../../api/declare.js";
let d = new Date();
let year = d.getFullYear();
export default {
  props: {
    companyName: {
      type: String,
      default: ""
    }
  },
  data() {
    return {
      thisYear: year,
      form: {
        frontYearMainOperatingIncome: 0,
        lastYearMainOperatingIncome: 0,
        lastYearOperatingIncome: 0,
        lastYearResearchCost: 0,
        lastYearTotalAssets: 0,
        lastYearTotalLiabilities: 0
      },
      companyInfo: {},
      visible: false
    };
  },
  methods: {
    getDetail() {
      getDeclareInnovate({ companyName: this.companyName }).then(res => {
        if (res.code === 200) {
          this.companyInfo = res.result;
        } else {
          this.$message({
            type: "warning",
            message: res.message
          });
        }
      });
    },
    onSave() {
      let params = [
        {
          value: this.form.frontYearMainOperatingIncome,
          text: `${this.thisYear - 2}年主营业务收入`
        },
        {
          value: this.form.lastYearMainOperatingIncome,
          text: `${this.thisYear - 1}年主营业务收入`
        },
        {
          value: this.form.lastYearResearchCost,
          text: `${this.thisYear - 1}年研发费`
        },
        {
          value: this.form.lastYearTotalAssets,
          text: `${this.thisYear - 1}年总资产`
        },
        {
          value: this.form.lastYearTotalLiabilities,
          text: `${this.thisYear - 1}年总负债`
        },
        {
          value: this.form.lastYearOperatingIncome,
          text: `${this.thisYear - 1}年营业收入`
        }
      ];
      for (let i = 0; i < params.length; i++) {
        let obj = params[i];
        let reg = /(^[1-9](\d+)?(\.\d{1,3})?$)|(^\d\.\d{1,3}$)/;
        if (!reg.test(obj.value)) {
          this.$message({
            message: `${obj.text}不能为0,最多三位小数`,
            type: "warning"
          });
          return;
        }
      }
      let form = Object.assign(this.form, { companyName: this.companyName });
      getDeclareInnovate(form).then(res => {
        if (res.code === 200) {
          this.companyInfo = res.result;
          this.$message({
            type: "success",
            message: "提交成功"
          });
          setTimeout(() => {
            this.onClose();
          }, 1000);
        } else {
          this.$message({
            type: "warning",
            message: res.message
          });
          this.onClose();
        }
      });
    },
    onDialog() {
      this.visible = true;
    },
    onClose() {
      this.visible = false;
      this.form.frontYearMainOperatingIncome = 0;
      this.form.lastYearMainOperatingIncome = 0;
      this.form.lastYearOperatingIncome = 0;
      this.form.lastYearResearchCost = 0;
      this.form.lastYearTotalAssets = 0;
      this.form.lastYearTotalLiabilities = 0;
    }
  }
};
</script>
<style lang="less" scoped src="./index.less"></style>